import axios from "axios"
const instance = axios.create();
instance.defaults.timeout = 2500;
// Add a request interceptor
instance.interceptors.request.use(function (config) {
    // Do something before request is sent
    return config;
  }, function (error) {
    let errorStatus = error.response

    if(error.code === "ECONNABORTED"){
        console.log("请求超时")
    }
    if(errorStatus === "404" ){
        console.log("请求未找到")
    } else if (errorStatus === "500" ){
        console.log("服务器错误")
    }
    // Do something with request error
    return Promise.reject(error);
  });

// Add a response interceptor
instance.interceptors.response.use(function (response) {
    // Do something with response data
    return response;
  }, function (error) {
    // Do something with response error
    return Promise.reject(error);
  });
export default instance
